package com.chenfan.process.enums;

import lombok.Getter;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * @author K
 * @date 2021/3/9
 * 执行的结果类型
 */
@Getter
public enum ProcessRelatedTypeEnums {
    /**
     * 创建
     */
    CREATED(1, "创建"),
    /**
     * 中间
     */
    MIDDLE(2, "过程"),
    /**
     * 结束
     */
    FINISH(3, "结束"),
    /**
     * 放弃
     */
    DISCARD(4, "放弃");
    private static final Map<Integer, ProcessRelatedTypeEnums> MAPPINGS;

    static {
        Map<Integer, ProcessRelatedTypeEnums> temp = new HashMap<>();
        for (ProcessRelatedTypeEnums mode : values()) {
            temp.put(mode.index, mode);
        }
        MAPPINGS = Collections.unmodifiableMap(temp);
    }

    private final Integer index;
    private final String name;

    ProcessRelatedTypeEnums(int index, String name) {
        this.index = index;
        this.name = name;
    }

    public static ProcessRelatedTypeEnums get(int index) {
        return MAPPINGS.get(index);
    }

    public static ProcessRelatedTypeEnums resolve(int index) {
        return MAPPINGS.get(index);
    }
}
